<?
  require_once("../init.php");
  include("../header.php");

  $image = new Image();
?>

<div id = "body">
<? $_SESSION["file_info"] = array(); ?>

<script type="text/javascript" src="swfupload/swfupload.js"></script>
<script type="text/javascript" src="js/handlers.js"></script>
<script type="text/javascript">
		var swfu;
		window.onload = function () {
			swfu = new SWFUpload({
				// Backend Settings
				upload_url: "upload-project-img.php",
				post_params: {"PHPSESSID": "<?php echo session_id(); ?>" , "project_id": "<?php echo $_GET['project_id']; ?>"},
				//post_params: {"project_id": "<?php echo $_GET['project_id']; ?>"},

				// File Upload Settings
				file_size_limit : "10 MB",
				file_types : "*.jpg;*.png;*.jpeg;*.gif",
				file_types_description : "Images",
				file_upload_limit : "0",

				// Event Handler Settings - these functions as defined in Handlers.js
				//  The handlers are not part of SWFUpload but are part of my website and control how
				//  my website reacts to the SWFUpload events.
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,

				// Button Settings
				button_placeholder_id : "spanButtonPlaceholder",
				button_width: 80,
				button_height: 18,
				button_text : 'เลือกรูป',
				button_text_top_padding: 2,
				button_text_left_padding: 18,
				button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
				button_cursor: SWFUpload.CURSOR.HAND,
				
				// Flash Settings
				flash_url : "swfupload/swfupload.swf",

				custom_settings : {
					upload_target : "divFileProgressContainer"
				},
				
				// Debug Settings
				debug: false
			});
		};
	</script>

<div id="content">
	<?php
	if( !function_exists("imagecopyresampled") ){

	} else {

	?>
	<form>
		<div style="border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;" align = "center">
			<span id="spanButtonPlaceholder"></span>
		</div>
	</form>
	<?php
	}
	?>
	<div id="divFileProgressContainer"></div>
	<div id="thumbnails"></div>
  <input type = "text" class = "none size2" id = "name" name = "name" onfocus = "this.select()">
</div>
<br>

<div align = "center"><input type = "button" value = "<?=__l("get name")?>" class = "btn" onClick ="get_name()"> <input type = "button" value = "<?=__l("close")?>" class = "btn" onClick = "javascript:self.close();window.opener.location.reload();"></div>
</div>

<script language = "javascript">
  function get_name(){
    retrieveURL("caption.php","name","value");
  }
</script>
<style>

  #thumbnails img{
    height:100px;
  }

  .none{
    background:none;
    border:none;
    color:#fff;
  }
</style>